<template>
    <div class="">
        <div class="title">
            <span>我的消息</span>
        </div>
        <div class="container">
            <!-- <el-tabs v-model="message"> -->
                <!-- <el-tab-pane label="所有产品" name="first"> -->
                    <el-table :data="unread" style="width: 100%">
                        <el-table-column align="center" width="100px">
                            <template slot-scope="scope" >
                                <span class="yuan" v-if="scope.row.hasRead == 0">未读</span>
                                <span class="yuan1" v-if="scope.row.hasRead == 1">已读</span>
                            </template>
                        </el-table-column>
                        <el-table-column align="center">
                            <template slot-scope="scope" >
                                <span class="message-conter">{{scope.row.description}}</span>
                                <el-button type="text" v-if="scope.row.type == 8" class="lianjie" @click="See()">去提现</el-button>
                            </template>
                        </el-table-column>
                        <el-table-column align="center">
                            <template slot-scope="scope">
                                <div class="message-conter">{{scope.row.createTime}}</div>
                            </template>
                        </el-table-column>
                    </el-table>
                <!-- </el-tab-pane> -->
            <!-- </el-tabs> -->
        </div>
    </div>
</template>

<script>
    import {jsyNoticeList, jsyNoticeRead} from '@/api/api';
    import md5 from "js-md5";
    export default {
        name: 'tabs',
        data() {
            return {
                message: 'first',
                showHeader: false,
                // unread: [{
                //     date: '2018-04-19 20:00:00',
                //     title: '【系统通知】该系统将于今晚凌晨2点到5点进行升级维护',
                // },{
                //     date: '2018-04-19 21:00:00',
                //     title: '今晚12点整发大红包，先到先得',
                // }],
                // read: [{
                //     date: '2018-04-19 20:00:00',
                //     title: '【系统通知】该系统将于今晚凌晨2点到5点进行升级维护'
                // }],
                // recycle: [{
                //     date: '2018-04-19 20:00:00',
                //     title: '【系统通知】该系统将于今晚凌晨2点到5点进行升级维护'
                // }],
                unread:[],
                username:''
            }
        },
        created(){
            this.getPermissions()
            this.jsyNoticeList()
        },
        methods: {
            // handleRead(index) {
            //     const item = this.unread.splice(index, 1);
            //     console.log(item);
            //     this.read = item.concat(this.read);
            // },
            // handleDel(index) {
            //     const item = this.read.splice(index, 1);
            //     this.recycle = item.concat(this.recycle);
            // },
            // handleRestore(index) {
            //     const item = this.recycle.splice(index, 1);
            //     this.read = item.concat(this.read);
            // },
            //获取权限
            getPermissions(){
            var aaa = sessionStorage.getItem('userInfo')
            var bbb = JSON.parse(aaa)
            this.username = bbb.username
            },
            jsyNoticeList(){
                jsyNoticeList({
                    merchantNo: this.username
                }).then(res => {
                    if(res.code == 405){
                        sessionStorage. removeItem('token')
                        this.$router.push('/login');
                    }else if(res.code == 200){
                        this.unread = res.data.list
                        this.jsyNoticeRead()
                    }
                })
            },
            jsyNoticeRead(){
                jsyNoticeRead({},this.username).then(res => {
                    if(res.code == 405){
                        sessionStorage. removeItem('token')
                        this.$router.push('/login');
                    }else if(res.code == 200){
                        // console.log(res)
                    }
                })
            },
            See(){
                // let url = 'http://jie2.test.jisucloud.cn/partner/entry'
                // let url = 'http://m.test.jisucloud.cn/partner/entry'
                let url = 'https://jie.jisujie.com/partner/entry'
                // let key = "4c9db51879546ea1605a4e4ad2c1e3ae"
                let key = "718afc3c29f92af7c8f26ba0c3b26c75"
                const now = new Date().getTime()
                let partner = 'partner=shoubei#$&ts='+ now +'#$&uid='+ this.username +'#$&key=' + key
                let sign = md5(partner)
                console.log(partner)
                window.open(url +'?ts='+ now +'&partner=shoubei&uid='+ this.username + '&sign=' + sign ); 
            },
        },
        computed: {
            unreadNum(){
                return this.unread.length;
            }
        }
    }

</script>

<style>
.title {
  background: #fff;
  padding: 10px 10px;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  justify-content: space-between;
}
.message-title{
    /* cursor: pointer; */
    font-size: 22px;
}
.handle-row{
    margin-top: 30px;
}
.message-title1{
    color: #999;
}
.message-conter{
    font-size: 16px;
}
.yuan{
    color: #FC7D46;
}
.yuan1{
    color: #999;
}
.lianjie{
    color: #FC7D46;
}
.message-type{
    font-size: 16px;
    color: #FC7D46
}
.message-type1{
    font-size: 16px;
}
</style>

